const mongoose = require('mongoose')
const {DataBaseHost, DataBasePort, DatabaseName} = require('../config')

module.exports = function(success,error){
    mongoose.connect(`mongodb://${DataBaseHost}:${DataBasePort}/${DatabaseName}`)
    mongoose.connection.on("open",()=>{
        console.log("database has connected")
        success()
    })

    mongoose.connection.on("error",()=>{
        error()
    })


    mongoose.connection.on("close",()=>{
        console.log("The database connection has been established");
    })
}